package com.wlz.listener;

import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.stereotype.Component;

/**
 * @author wlz
 * @date 2022-06-28  11:05 下午
 */
@Slf4j
@Component
public class QosListener implements ChannelAwareMessageListener {

    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
        // 获取 消息id
        long deliveryTag = message.getMessageProperties().getDeliveryTag();

        // 1. 获取 消息
        log.info("message: {}", new String(message.getBody()));

        // 2. 处理业务逻辑

        // 3. 进行消息手动签收
//        channel.basicAck(deliveryTag, true);



    }
}
